package arch.dao.impl.manager;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

import org.springframework.jdbc.core.BatchPreparedStatementSetter;

import arch.domain.manager.ArchLogger;
/**
 * 
 * @author <a mailto="wanglong635@126.com">Long</a>
 *
 */
public class ArchLoggerAddSetter implements BatchPreparedStatementSetter {
	private List<ArchLogger> loggers;
	
	public ArchLoggerAddSetter(List<ArchLogger> loggers){
		this.loggers = loggers;
	}
	public int getBatchSize() {
		return loggers.size();
	}

	public void setValues(PreparedStatement ps, int i) throws SQLException {
		ps.setString(1, loggers.get(i).getId());
		ps.setString(2, 
				loggers.get(i).getOperator()==null?null:loggers.get(i).getOperator().getUserId());
		ps.setString(3, 
				loggers.get(i).getOperator()==null?null:loggers.get(i).getOperator().getUserName());
		ps.setString(4, 
				loggers.get(i).getOperatorDept()==null?null:loggers.get(i).getOperatorDept().getDeptId());
		ps.setString(5, 
				loggers.get(i).getOperatorDept()==null?null:loggers.get(i).getOperatorDept().getDeptName());
		ps.setString(6, loggers.get(i).getLoginIp());
		ps.setString(7, loggers.get(i).getArchId());
		ps.setString(8, loggers.get(i).getModuleName());
		ps.setString(9, loggers.get(i).getOperatContent());
		ps.setString(10, loggers.get(i).getDetail());
		ps.setString(11, loggers.get(i).getType()==null?null:loggers.get(i).getType().name());
		ps.setString(12, loggers.get(i).getSubType());
		ps.setTimestamp(13, loggers.get(i).getClientOperateTime());
		ps.setTimestamp(14, loggers.get(i).getServerCurrentTime());
		ps.setTimestamp(15, loggers.get(i).getServerRunTime());
		ps.setString(16, loggers.get(i).getResult()?"1":"0");
		ps.setString(17, loggers.get(i).getDelete()?"1":"0");
	}

}
